/* 
 * Copyright [2018] [Alex/libo(liboware@gmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.network.core;


import com.hyts.network.task.AbstractExecutor;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

/** 
 * @author LiBo/Alex
 * @since V1.0
 * @version V1.0 
 */
public interface Server {

    /** 
          *默认为true 启动状态
     */
    AtomicBoolean status = new AtomicBoolean(true);
    
    /**
          * 计入结果集队列
     */
    AtomicBoolean injectResultList = new AtomicBoolean(false);
    
    /**  
     * <p>启动次数</p> 
     * @fieldName startNum
     * @fieldType int
     */ 
    AtomicInteger startNum= new AtomicInteger(0);

    /**
     * 结果集
     */
    Queue<Future<?>> resultList = new ConcurrentLinkedQueue<Future<?>>();

    /**  
     * @param statusType
     * @exception
     */ 
    default void setStatus(boolean statusType) {
        status.set(statusType);
    }
    
    /**  
     * @param statusType
     * @exception
     */ 
    default void setInjectResultList(boolean statusType) {
        injectResultList.set(statusType);
    }


    default boolean getInjectResultList(){
        return injectResultList.get();
    }


    /**
     * 启动操作
     * @param executor
     */
    void start(AbstractExecutor<?, ?, ?> executor);

    /**
     * 停止操作
     */
    void stop();

    /**
     * 是否已经关闭
     * @return
     */
    boolean isClosed();

}
